<template>
  <div class="content-box">
    <nav-title title="社保及个人档案信息" />
    <div class="line">
      <span class="important"></span>
      <div class="label">账户类型</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="socsec.cDescr" disabled>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">未参加过</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="lcList" v-model="socsec.cYesNo"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">账号</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="socsec.gpcnAcountNum" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">原缴纳地</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="socsec.cAddress" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">状态</div>
      <div class="value">
      <group label-width="5em">
        <popup-radio placeholder="请选择" readonly :options="staVal" v-model="socsec.cPhfStatus"></popup-radio>
      </group>
      </div>
    </div>


    <div class="bsbtn" @click="save" v-if="showOr">
      保存
    </div>
  </div>

</template>

<script>
import { Group, PopupRadio  } from 'vux'
import { getDicItem,savePsoc } from '../../../api/api'
import { json2Form } from '../../../util/http'

export default {

  name: 'input-information',
  components: {
    Group, PopupRadio
  },
  mounted(){
    //获取字典
    this.getstaDic()
  },
  created() {
    this.getCocs()
  },
  data() {
    return {
      socsec:{
        emplid: '10070226',
        cTransactionNbr:''
      },
      showOr:true,
      staVal:[],
      lcList: [{value: '有', key: 'Y'},{value: '无', key: 'N'}],
    }
  },
  methods: {

      //状态
      getstaDic(){
        this.staVal = []
        let params = {
          fileName: 'C_PHF_STATUS'
        }
        getDicItem(params).then(res => {
          res.retData.forEach((val) => {
            this.staVal.push({value: val.xlatshortname, key: val.fieldvalue})
          });
        }).catch(res => {

        })
      },

    save() {
      this.socsec.cModStauts = 'U'
      savePsoc(json2Form(this.socsec)).then(res => {
        console.log(res)
        const that = this;
        //成功：000000
        if(res && res.retCode === '000000' ){
          //保存成功
          // 显示
          this.$vux.alert.show({
            title: '奥克斯',
            content: '保存成功',
            onHide () {
              that.$router.push({
                name: 'userBase',
                params:{
                  cnta: that.socsec.cTransactionNbr
                }
              });
            }
          })

        }else{
          // 显示
          this.$vux.alert.show({
            title: '提示',
            content: res.retMsg
          })
        }
      }).catch (res=>{
        this.$vux.alert.show({
          title: '警告',
          content: '网络异常，请稍后重试'
        })
      })

    },

    getCocs() {
      if(this.$route.params.socvl){
        this.socsec = this.$route.params.socvl
        this.socsec.cTransactionNbr = this.$route.params.ctn
        if(!this.$route.params.ctn){
          this.showOr = false
        }
      }
    }

  }
}
</script>
<style type="text/scss" lang="scss">
@import "./personstyle";
</style>
